package leetcode

func maxArea(heigh []int) int {
	max, start, end := 0, 0, len(heigh)-1
	for start < end {
		width := end - start
		high := 0
		if heigh[start] < heigh[end] {
			high = heigh[start]
			start++
		} else {
			high = heigh[end]
			end--
		}

		tmp := width * high
		if tmp > max {
			max = tmp
		}

	}
	return max
}

func maxArea_fan(height []int) int {
	if len(height) < 2 {
		return 0
	}

	max := 0

	for i := 0; i < len(height); i++ {
		for j := i + 1; j < len(height); j++ {
			var tmpMax int
			if height[i]-height[j] > 0 {
				tmpMax = (j - i) * height[j]
			} else {
				tmpMax = (j - i) * height[i]
			}
			if tmpMax > max {
				max = tmpMax
			}
		}
	}

	return max
}
